using System;
using UnityEngine.UIElements;

namespace DA.AnimGraph.Editor {
    internal class InspectorField_Layer : InspectorField<AGAFieldModel_Layer> {

        InspectorField_FloatLink weightField;
        InspectorField_MaskLink maskField;
        Toggle isAdditiveField;


        protected override void BuildUI() {
            weightField = new InspectorField_FloatLink();
            weightField.Init("weight", source.weight, ageContext, OnChanged);

            maskField = new InspectorField_MaskLink();
            maskField.Init("mask", source.mask, ageContext, OnChanged);

            isAdditiveField = new Toggle("is additive");
            isAdditiveField.value = source.isAdditive;
            isAdditiveField.RegisterValueChangedCallback(evt => OnChanged());
        }


        protected override void DrawUI() {
            Add(isAdditiveField);
            Add(maskField);
            Add(weightField);
        }

        private void OnChanged() {
            source.isAdditive = isAdditiveField.value;

            inspectorChangeCallback?.Invoke();
        }

    }


}
